package com.mscsoft.brainpower.server.action;

import javax.annotation.Resource;

import com.mscsoft.brainpower.server.domain.*;
import com.mscsoft.brainpower.server.service.UserService;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserAction {

    @Resource
    UserService userService;

    @RequestMapping("/register")
    public Msg<Object> register(String account, String password, String checkCode) {
        return userService.register(account, password, checkCode);
    }

    @RequestMapping("/login")
    public Msg<Object> login(String account, String password) {
        return userService.login(account, password);
    }

    @RequestMapping("/nicknameUpdate")
    public Msg<Object> nicknameUpdate(String account, String password, String nickname) {
        return userService.nicknameUpdate(account, password, nickname);
    }

    @RequestMapping("/pswUpdate")
    public Msg<Object> pswUpdate(String account, String oldPassword, String newPassword) {
        return userService.pswUpdate(account, oldPassword, newPassword);
    }

    @RequestMapping("/findPsw")
    public Msg<Object> findPsw(String account, String checkCode, String newPassword) {
        return userService.findPsw(account, checkCode, newPassword);
    }

    /** 发送验证码 */
    @RequestMapping("/sendCheckCode")
    public Msg<Object> sendCheckCode(String mail) {
        return userService.sendCheckCode(mail);
    }

}
